package com.tansun.easycare.rule.deployonline.entity;

import org.hibernate.validator.constraints.Length;

import com.tansun.easycare.rule.common.entity.RuleBaseEntity;

/**
 * 规则发布Entity
 *
 * @author lixs
 * @version 2017-04-11
 */

public class RuleDeployment extends RuleBaseEntity<RuleDeployment> {

    private static final long serialVersionUID = 1L;
    private String deployName;        // 发布名称
    private String deployCode;
    private String projectName;        // 规则库名
    private String projectCode;        // 规则库编码
    private String userName;        // 上传用户名
    private String password;        // 上传密码
    private String serverUrl;        // 上传服务地址
    private String statusInd;
    private String calcStatus="0"; 		//计算状态
    private String uploadStatus="0";	//数据是否上传
	private String fileName;//上传数据文件名称
	private String fileOrSql="file";//数据文件或者sql
	private String dataSql;//查询sql
    /**
     * 扩展字段
     */
    private String enterPoints;


    /**
     * 创建人
     */
    private String createdName;

    /**
     * 修改人
     */
    private String modifiedBy;
    
    
    private String  currUserNum;
    
    
    /**
     * 规则模型ID
     */
    private String manageId;
    public RuleDeployment() {
        super();
    }

    public RuleDeployment(String id) {
        super(id);
    }

	public com.tansun.ruledata.entity.RuleDeployment changeClass(){
		com.tansun.ruledata.entity.RuleDeployment newinfo = new com.tansun.ruledata.entity.RuleDeployment();
		newinfo.setDeployCode(deployCode);
		newinfo.setDeployName(deployName);
		newinfo.setEnterPoints(enterPoints);
		newinfo.setId(id);
		newinfo.setPassword(password);
		newinfo.setProjectCode(projectCode);
		newinfo.setProjectName(projectName);
		newinfo.setServerUrl(serverUrl);
		newinfo.setStatusInd(statusInd);
		newinfo.setUserName(userName);
		return newinfo;
	}
	
    @Length(min = 0, max = 50, message = "发布名称长度必须介于 0 和 50 之间")
    public String getDeployName() {
        return deployName;
    }

    public void setDeployName(String deployName) {
        this.deployName = deployName;
    }

    @Length(min = 0, max = 50, message = "规则库名长度必须介于 0 和 50 之间")
    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    @Length(min = 0, max = 50, message = "规则库编码长度必须介于 0 和 50 之间")
    public String getProjectCode() {
        return projectCode;
    }

    public void setProjectCode(String projectCode) {
        this.projectCode = projectCode;
    }

    @Length(min = 0, max = 50, message = "上传用户名长度必须介于 0 和 50 之间")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Length(min = 0, max = 50, message = "上传密码长度必须介于 0 和 50 之间")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Length(min = 0, max = 100, message = "上传服务地址长度必须介于 0 和 100 之间")
    public String getServerUrl() {
        return serverUrl;
    }

    public void setServerUrl(String serverUrl) {
        this.serverUrl = serverUrl;
    }


    public String getCreatedName() {
        if (this.createBy != null) {
            //User user = UserUtils.get(this.createBy.getId());
            return this.createBy;
        }
        return createdName;
    }

    public String getModifiedBy() {
        if (this.updateBy != null) {
           // User user = UserUtils.get(this.updateBy.getId());
            return this.updateBy;
        }
        return modifiedBy;
    }

    public String getDeployCode() {
        return deployCode;
    }

    public void setDeployCode(String deployCode) {
        this.deployCode = deployCode;
    }

    public String getStatusInd() {
        return statusInd;
    }

    public void setStatusInd(String statusInd) {
        this.statusInd = statusInd;
    }

	public String getEnterPoints() {
		return enterPoints;
	}

	public void setEnterPoints(String enterPoints) {
		this.enterPoints = enterPoints;
	}
	
//	public String getSql() {
//		return "insert rule_deployment (id,deploy_name,project_name,project_code,server_url,create_date,create_by,status_ind,data_version) values(?,?,?,?,?,?,?,?,?)";
//	}
//	public Object[] getArgs(String timeStamp) {
//		return new Object[] {this.id,this.deployName,this.projectName,this.projectCode,this.serverUrl,new Date(),this.createdName,"1",timeStamp};
//	}
	 
	public String getManageId() {
		return manageId;
	}

	public void setManageId(String manageId) {
		this.manageId = manageId;
	}

	public String getSql() {
		return "insert Into rule_deployment (id,deploy_name,project_name,project_code,server_url,create_date,create_by,status_ind,data_version) values ";
	}
	public String getArgs(String timeStamp) {
		return "('"+this.id+"','"
				   +isEmpty(this.deployName)+"','"
				   +isEmpty(this.projectName)+"','"
				   +isEmpty(this.projectCode)+"','"
				   +isEmpty(this.serverUrl)+"',@currDate,'"
				   +isEmpty(this.createdName)+"','1','"
				   +timeStamp+"')";
//		return new Object[] {this.id,this.deployName,this.projectName,this.projectCode,this.serverUrl,new Date(),this.createdName,"1",timeStamp};
	}
	public String getArgs(String timeStamp,String currDate) {
		return "('"+this.id+"','"
				   +isEmpty(this.deployName)+"','"
				   +isEmpty(this.projectName)+"','"
				   +isEmpty(this.projectCode)+"','"
				   +isEmpty(this.serverUrl)+"','"+currDate+"','"
				   +isEmpty(this.createdName)+"','1','"
				   +timeStamp+"')";
//		return new Object[] {this.id,this.deployName,this.projectName,this.projectCode,this.serverUrl,new Date(),this.createdName,"1",timeStamp};
	}

	public String getCalcStatus() {
		return calcStatus;
	}

	public void setCalcStatus(String calcStatus) {
		this.calcStatus = calcStatus;
	}

	public String getUploadStatus() {
		return uploadStatus;
	}

	public void setUploadStatus(String uploadStatus) {
		this.uploadStatus = uploadStatus;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFileOrSql() {
		return fileOrSql;
	}

	public void setFileOrSql(String fileOrSql) {
		this.fileOrSql = fileOrSql;
	}

	public String getDataSql() {
		return dataSql;
	}

	public void setDataSql(String dataSql) {
		this.dataSql = dataSql;
	}

	public String getCurrUserNum() {
		return currUserNum;
	}

	public void setCurrUserNum(String currUserNum) {
		this.currUserNum = currUserNum;
	}
	
	
	
}